<layout name="Common/common" />
<style>
    .fil{
        margin-top:5px;
    }
    .remove{
        position:relative;
        top:10px;
        left:90%;
    }
</style>
<div class="tab-div">
    <div id="tabbar-div">
        <p>
            <span class="tab-front" >基本信息</span>
            <span class="tab-back" >电参数</span>
            <span class="tab-back" >产品图片</span>
            <span class="tab-back" >外形尺寸及特性</span>
            <span class="tab-back" >其他图形</span>
        </p>
    </div>
    <div id="tabbody-div">
        <form enctype="multipart/form-data" action="__SELF__" method="post">
            <input type="hidden" name="id" value="{$info.id}">
            <table width="90%" class="general-table" align="center">
                <tr>
                    <td class="label">系列编码：</td>
                    <td>
                        <input style="color:red;" type="text" name="cpxlno" size="60" value="{$info.cpxlno}" readonly="readonly" >
                    </td>
                </tr>
                <tr>
                    <td class="label">系列名称：</td>
                    <td>
                        <input style="color:red;" type="text" name="xlmc" size="60" value="{$info.xlmc}" readonly="readonly" >
                    </td>
                </tr>
                <tr>
                    <td class="label">系列简介：</td>
                    <td>
                        <textarea name="intro" cols="80" rows="6">{$info.intro}</textarea>
                    </td>
                </tr>
                <tr>
                    <td class="label"><h4>技术标准：</h4></td>
                    <td>
                        <?php foreach($info['skill'] as $k=>$v){
                        if($k == 0){
                            $html='[ + ]';
                        }else{
                             $html='[ - ]';
                        } ?>
                        <p><a href="javascript:;" onclick="bz(this);"><?php echo $html;?></a>  <input type="text" name="skill[]" value="{$v}"size="60" /></p>
                        <?php } ?>
                    </td>
                </tr>

                <tr>
                    <td class="label">降功耗说明：</td>
                    <td>
                        <input type="text" name="jghsm" value="{$info.jghsm}" size="60"/>
                    </td>
                </tr>
                <tr>
                    <td class="label">降功耗曲线图：</td>
                    <td>
                        <?php if($info[jgh_img]){ ?>
                            <?php echo showimage($info['jgh_img'],300);?>
                        <?php }else{ ?>
                            暂无图片
                        <?php } ?>
                        <input type="file" name="jgh_img" size="35" />
                    </td>
                </tr>
                <tr>
                    <td class="label">订货标识图：</td>
                    <td>
                        <?php if($info[jgh_img]){ ?>
                            <?php echo showimage($info['dhsl_img'],300);?>
                        <?php }else{ ?>
                            暂无图片
                        <?php } ?>
                        <input type="file" name="dhsl_img" size="35" />
                    </td>
                </tr>
                <tr>
                    <td class="label"><h4>说明：</h4></td>
                    <td>
                        <?php foreach($info['sm'] as $k=>$v){
                        if($k == 0){
                            $html='[ + ]';
                        }else{
                            $html='[ - ]';
                        } ?>
                        <p><a href="javascript:;" onclick="bz(this);"><?php echo $html;?></a>  <input type="text" name="sm[]" value="{$v}"size="60" /></p>
                        <?php } ?>
                    </td>
                </tr>
            </table>
            <table width="90%" class="general-table" align="center" style="display:none">
                <tr>
                    <td class="label">电参数</td>
                    <td>
                        <ul class="diancs">
                            <foreach name="info['dianc']" item="v">
                            <p>
                                <li>
                                    <a href="javascript:;" onclick="remove(this);" >[ - ]</a>
                                    <input type="text" readonly="readonly" name="dcname[{$v.electriparam_id}]"  value="{$v.electriparam_name}" size="30">
                                    <select name="sign[{$v.electriparam_id}];?>]">
                                        <option value="＝" <?php if($v['electriparam_sign'] == '＝') echo "selected='selected'";?>>＝</option>
                                        <option value="≤" <?php if($v['electriparam_sign'] == '≤') echo "selected='selected'";?>>≤</option>
                                        <option value="≥" <?php if($v['electriparam_sign'] == '≥') echo "selected='selected'";?>>≥</option>
                                    </select>
                                    <input type="text" name="dcsval[{$v.electriparam_id}]" value="{$v.electriparam_val}" size="40">
                                </li>
                            </p>
                            </foreach>
                        </ul>
                    </td>
                </tr>
                <tr>
                    <td class="label"><a href="javascript:;" onclick="ct(this);" >[ + ]</a> 自定义电参数：</td>
                    <td >
                        <select name="zdy_dcs[]" >
                            <option value="">请选择</option>
                            <foreach name="diancanshu" item="v">
                                <option value="{$v.id}---{$v.name}">{$v.name}</option>
                            </foreach>
                        </select>
                        <select name="zdy_sign[]" >
                            <option value="＝">＝</option>
                            <option value="≤">≤</option>
                            <option value="≥">≥</option>
                        </select>
                        <input type="text" class="p3" name="zdy_dcsval[]" size="40">
                    </td>
                </tr>
            </table>
            <table width="90%" class="general-table" align="center" style="display:none">
                <tr>
                    <td class="label"><input type="button" class="but" value="添加产品相册"></td>
                    <td>
                        <ul class="ul"></ul>
                        <foreach name="info['img']" item="c">
                            <a href="javascript:;" title="点击删除" img_id="{$c.id}" onclick="removeimg(this);"><?php echo showimage($c['img'],300);?></a><br>
                        </foreach>
                    </td>
                </tr>
            </table>
            <table width="90%" class="general-table" align="center" style="display:none">
                <tr >
                    <td class="label"><a href="javascript:;" onclick="ct(this);">[ + ]</a> 说明：</td>
                    <td>
                        <input type="text" name="ct_intro[]" size="60" ><br>
                        <input class="fil" type="file" name="ct_img[]" id="">
                    </td>
                </tr>
                <foreach name="info['ct']" item="c">
                <tr >
                    <td class="label"><a href="javascript:;" onclick="remove_ct(this);" ct_id="{$c.id}" title="点击删除"><img src="__PUBLIC__/admin/images/remove.png" width="20" alt=""></a> 说明：</td>
                    <td>
                        <input type="text" name="ct_intro[]" value="{$c.ct_intro}" size="20" readonly="readonly"><br>
                        <?php echo showimage($c['ct_img'],300); ?>
                    </td>
                </tr>
                </foreach>
            </table>
            <table width="90%" class="general-table" align="center" style="display:none">
                <tr style="margin-bottom:10px" >
                    <td class="label">
                        <a href="javascript:;" onclick="ct(this);" >[ + ]</a>
                        名称 : <input type="text" name="qt_name[]">
                    </td>
                    <td>
                        说明 : <input type="text" name="qt_intro[]" size="60"><br>
                        <input class="fil" type="file" name="qt_img[]" >
                    </td>
                </tr>

                <foreach name="info['qt']" item="v">
                <tr >
                    <td class="label">
                        <a href="javascript:;" onclick="remove_qt(this);" qt_id="{$v.id}" ><img src="__PUBLIC__/admin/images/remove.png" width="20" alt=""></a>
                        名称 : <input type="text" name="qt_name[]" value="{$v.qt_name}" readonly="readonly">
                    </td>
                    <td>
                        说明 : <input type="text" name="qt_intro[]" size="60" value="{$v.qt_intro}" readonly="readonly"><br>
                        <?php echo showimage($v['qt_img'],300); ?>
                    </td>
                </tr>
                </foreach>
            </table>
            <div class="button-div">
                <input type="submit" value=" 确定 " class="button"/>
                <input type="reset" value=" 重置 " class="button" />
            </div>
        </form>
    </div>
</div>

<script>
    function remove(a){
        $(a).parent().remove();
    }
    //删除产品相册
    function removeimg(a){
        if(confirm('确定要删除这张图片吗?')){
            var id = $(a).attr('img_id');
            var dbname = 'xl_img';
            $.get('__CONTROLLER__/ajax_remove/id/'+id+'/dbname/'+dbname,function(vs){
                if(vs == true){
                    $(a).remove();
                }else{
                    alert('图片删除失败');
                }

            });
        }
    }
    //删除产品尺寸和特性
    function remove_ct(a){
        if(confirm('确定要删除这条数据吗?')){
            var id = $(a).attr('ct_id');
            var dbname = 'size_img';
            $.get('__CONTROLLER__/ajax_remove/id/'+id+'/dbname/'+dbname,function(vs){
                if(vs == true){
                    $(a).parent().parent().remove();
                }else{
                    alert('删除失败');
                }

            });
        }
    }

    //删除产品其他图谱
    function remove_qt(a){
        if(confirm('确定要删除这条数据吗?')){
            var id = $(a).attr('qt_id');
            var dbname = 'xl_other_img';
            $.get('__CONTROLLER__/ajax_remove/id/'+id+'/dbname/'+dbname,function(vs){
                if(vs == true){
                    $(a).parent().parent().remove();
                }else{
                    alert('删除失败');
                }

            });
        }
    }
    //添加技术标准
    function bz(a){
        var main = $(a).parent();
        if($(a).html() == '[ + ]'){
            var newp = main.clone();
            newp.find('a').html('[ - ]');
            newp.find('input').val('');
            main.after(newp);
        }else{
            main.remove();
        }
    }
    //点击模块更改样式
    $('#tabbar-div p span').click(function(){
        var i = $(this).index();
        $('.general-table').hide();
        $('.general-table').eq(i).show();
        $('.tab-front').removeClass('tab-front').addClass('tab-back');
        $(this).removeClass('tab-back').addClass('tab-front')
    });

    //添加产品图片按钮
    $('.but').click(function(){
        var html = '<p><li><input type="file" name="xl_img[]"><a href="javascript:;" onclick="remove(this);">[ - ]</a></li></P>';
        $('.ul').append(html);
    })
    //删除产品图片按钮
    function remove(a){
        $(a).parent().remove();
    }

    //添加尺寸和特性按钮
    function ct(a){
        var main = $(a).parent().parent();
        if($(a).html() == '[ + ]'){
            var newtr = main.clone();
            newtr.find('td a').html('[ - ]');
            newtr.find('td input').val('');
            main.after(newtr);
        }else{
            main.remove();
        }
    }
</script>
